package com.newland.esp.controller.echarts;

import com.newland.esp.common.util.DataResult;
import com.newland.esp.entity.deviceEntity.DeviceInfoEntity;
import com.newland.esp.mapper.echarts.BarMapper;
import com.newland.esp.service.echarts.BarService;
import com.newland.esp.vo.response.echarts.BarVo;
import com.newland.esp.vo.response.echarts.PieAndBarVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @param
 * @author lw
 * @descripe
 * @date 2021/8/22 11:06
 * @Version 1.0
 **/
@Controller
@CrossOrigin
@RequestMapping("/echarts")
public class BarController {
    @Autowired
    BarService barService;
    @Resource
    BarMapper barMapper;

    @RequestMapping("/getBarDate")
    @ResponseBody
    public DataResult getBarDate(){
        BarVo barDate = barService.getBarDate();
        return DataResult.success(barDate);
    }

    @RequestMapping("/getPie")
    @ResponseBody
    public DataResult getPieVO(){
        List<PieAndBarVO> result = barMapper.selectDeviceCount();
        return DataResult.success(result);
    }

}
